//
//  YCForgetPasswordTextField.m
//  YCSchool
//
//  Created by Yanglixia on 16/5/9.
//  Copyright © 2016年 yanglinxia. All rights reserved.
//

#import "YCForgetPasswordTextField.h"

@implementation YCForgetPasswordTextField

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.layer.borderWidth = 1;
        self.layer.borderColor = [UIColor yc_colorWithUInt:0xe0e0e0].CGColor;
        self.layer.cornerRadius= 17.5;
        self.layer.masksToBounds = YES;
        self.backgroundColor = [UIColor whiteColor];
        self.clearButtonMode = UITextFieldViewModeWhileEditing;
        self.font = [UIFont systemFontOfSize:15];
        self.textColor = [UIColor yc_colorWithUInt:0x3d3e40];
        self.returnKeyType = UIReturnKeyDone;
        self.placeholder = @"请输入验证码";
        UILabel *tipLabel = [[UILabel alloc] init];
        tipLabel.font = [UIFont boldSystemFontOfSize:15];
        CGSize tipLabelSize = [@"注册手机号" yc_sizeWithFont:tipLabel.font MaxSize:CGSizeMake(CGFLOAT_MAX, 0)];
        tipLabel.frame = CGRectMake(0, 0, tipLabelSize.width + 34, 40);
        tipLabel.textColor = [UIColor yc_colorWithUInt:0x3d3e40];
        tipLabel.text = @"验证码";
        tipLabel.textAlignment = NSTextAlignmentLeft;
        self.leftView = tipLabel;
        self.leftViewMode = UITextFieldViewModeAlways;
        
        UIButton *rightViewBtn = [[UIButton alloc] init];
        rightViewBtn.titleLabel.font = [UIFont systemFontOfSize:9];
        rightViewBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
        CGSize rightViewBtnSize = [@" 获取验证 " yc_sizeWithFont:rightViewBtn.titleLabel.font MaxSize:CGSizeMake(CGFLOAT_MAX, 0)];
        [rightViewBtn setTitle:@"获取验证" forState:UIControlStateNormal];
        [rightViewBtn setTitleColor:[UIColor yc_colorWithUInt:0x3d3e40] forState:UIControlStateNormal];
        rightViewBtn.frame = CGRectMake(0, 0, rightViewBtnSize.width+12, 26);
        rightViewBtn.layer.cornerRadius= 13;
        rightViewBtn.layer.masksToBounds = YES;
        rightViewBtn.backgroundColor = [UIColor yc_colorWithUInt:0xf8bb36];
        self.rightViewBtn = rightViewBtn;
        self.rightView = rightViewBtn;
        self.rightViewMode = UITextFieldViewModeAlways;
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    CGSize rightViewBtnSize = [@" 获取验证 " yc_sizeWithFont:[UIFont systemFontOfSize:9] MaxSize:CGSizeMake(CGFLOAT_MAX, 0)];
    self.leftView.yc_x = 17;
    self.rightView.yc_x = self.yc_width - 7 - rightViewBtnSize.width - 12;
}


@end
